package eScrum.components;

import org.apache.wicket.Component;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.html.IHeaderResponse;

/**
 * Centers the window on screen by taking into consideration the scroll bars. <br>
 * It calls centerWindowOnScreen() if is available.
 * 
 */
public class CenterWindowOnScreenBehavior extends Behavior {

	private static final long serialVersionUID = 1L;
	Component component;

	@Override
	public void bind(Component component) {
		component.setOutputMarkupId(true);
	}

	@Override
	public void renderHead(Component component, IHeaderResponse response) {
		super.renderHead(component, response);
		response.renderOnLoadJavaScript("if(typeof centerWindowOnScreen == 'function') {centerWindowOnScreen();}");
	}
}